Skip to content

WIP: Optimized matcher #3707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from
Closed

WIP: Optimized matcher #3707

wants to merge 17 commits into from

Conversation

iurisilvio
Copy link
Contributor

This is a draft implementation with some new ideas.

  • Static paths don't need regex match for most cases.
  • Match don't have to be always linear, it is possible to match only with static paths.

Regex match is 10x slower than simple object access. I still have to run some dynamic matches to not break ordering compatibility.

I still want to integrate it better with current code, I did this implementation to validate the issue and run some benchmarks.

@netlify
Copy link

netlify bot commented Jan 30, 2022

✔️ Deploy Preview for vue-router-docs-v3 canceled.

🔨 Explore the source changes: 7b4b084

🔍 Inspect the deploy log: https://app.netlify.com/sites/vue-router-docs-v3/deploys/61f6f32903b198000767f58d

@iurisilvio
Copy link
Contributor Author

I did a small benchmark script to prove the concept, in my own machine.

https://gist.github.com/iurisilvio/a916ce2de16336ec97aab8db5525f7f9

For 100 static routes, current vue-router takes 14ms average to resolve and my version takes less than 1ms.

Even to resolve the first result, it is 30% slower because it evaluates one regex.

@iurisilvio
Copy link
Contributor Author

For dynamic paths, it will evaluate only part of the routes, based on first level path. If you have 100 rules but only 5 starting with the same first level path, it will evaluate at most 5 rules.

@buserbrasil buserbrasil closed this by deleting the head repository Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants